package numberslider;

import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;
import java.util.Vector;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: Dec 22, 2009
 * Time: 10:38:33 PM
 * To change this template use File | Settings | File Templates.
 */
public class AnalysTableModel extends AbstractTableModel  {


    //    private String analysName = "default";
    private Vector<String> columNames;
    private Vector<Vector> data;

    public AnalysTableModel(String analysName) {
        columNames = getColumnNames(analysName);
        data = getTableData(analysName);
    }


    @Override
    public int getRowCount() {
        return data.size();
    }

    @Override
    public int getColumnCount() {
        return columNames.size();
    }

    public String getColumnName(int col) {
        return columNames.elementAt(col);
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return data.elementAt(rowIndex).elementAt(columnIndex);
    }

// public boolean isCellEditable(int row, int col) {
//     return true;
// }
//    public void setValueAt(Object value, int row, int column) {
//        ((Vector) data.elementAt(row)).setElementAt(value, column);
//        fireTableCellUpdated(row, column);
//        fireTableCellUpdated(row, column);
//    }


    private Vector<String> getColumnNames(String analysName) {
        Vector<String> toReturn = new Vector<String>(5);
        toReturn.add(analysName);
        toReturn.add(analysName);
        toReturn.add(analysName);
        toReturn.add(analysName);
        toReturn.add(analysName);
        return toReturn;
    }

    private Vector<Vector> getTableData(String data) {
        Vector<Vector> toReturn = new Vector<Vector>();
        Vector row = new Vector<String>(5);
        for (int z = 0; z < 10; z++) {
            for (int i = 0; i < 5; i++) {
                row.add(data + i);
            }

            toReturn.add(row);
        }
        return toReturn;
    }


}
